package com.cloudfunx.common.util;

import lombok.SneakyThrows;

/**
 * @author heiansl
 */
public class CusOptional<T> {
    private T value;

    private CusOptional(){}

    private CusOptional(T value) {
        this.value = value;
    }

    @SneakyThrows
    public static <T> CusOptional<T> of(T value, Class<T> clz) {
        return value == null ? new CusOptional<>(clz.newInstance()) : new CusOptional<>(value);
    }

    public T get() {
        return value;
    }
}
